//
//  InsuranceRulesController.m
//  LocomotiveGuards
//
//  Created by iOS app dev on 16/8/24.
//  Copyright © 2016年 REDOOR. All rights reserved.
//

#import "InsuranceRulesController.h"
#import "XDMultTableView.h"
#import "LawViewController.h"


@interface InsuranceRulesController () <XDMultTableViewDelegate,XDMultTableViewDatasource>
@property(nonatomic,strong) UITextView *textfield;

@property(nonatomic, readwrite, strong)XDMultTableView *tableView;
@property (nonatomic,strong) UITableView *tableview2;



@end

@implementation InsuranceRulesController

- (void)viewDidLoad {
     [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
//    _tableView = [[XDMultTableView alloc] initWithFrame:CGRectMake(0, 20+44*H,SCREEN_WIDTH, SCREEN_HEIGHT-20-44*H-48)];
//    _tableView.delegate = self;
//    _tableView.datasource = self;
//    _tableView.backgroundColor = [UIColor whiteColor];
//    [self.view addSubview:_tableView];
    
    self.tableview2 = [[UITableView alloc]initWithFrame:CGRectMake(0, 20+44*H, SCREEN_WIDTH, SCREEN_HEIGHT-20-44*H-48) style:UITableViewStyleGrouped];
    self.tableview2.delegate = self;
    self.tableview2.dataSource = self;
    [self.view addSubview:self.tableview2];
//    self.tableview2.backgroundColor = [UIColor greenColor];
    
    
    
      [self createMyNav];
}

- (void)createMyNav
{
    self.view.backgroundColor = [UIColor colorWithRed:239.0/255 green:239.0/255 blue:244.0/255 alpha:1];
    [self addTitle:@"保险条例" imageName:@"保险条例"];
    [self addBackBtnTarget:self action:@selector(backBtnClick)];
}


#pragma mark - 点击事件
- (void)backBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma  mark tableview delegate
-(NSInteger)numberOfSectionsInTableView:(XDMultTableView *)mTableView
{

    return 1;

}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return 3;

}



-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 44;

}


-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{

    return 0.01;

}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *IdentifierCell = @"Cell";
    
    UITableViewCell * cell = [self.tableview2 dequeueReusableCellWithIdentifier:IdentifierCell];
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:IdentifierCell];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.backgroundColor = [UIColor whiteColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    return cell;


}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{


    NSInteger row = [indexPath row];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    LawViewController *law = [[LawViewController alloc]initWithNibName:nil bundle:nil];
    law.number = &(row);
    
    NSLog(@"获取的行数是  %zd",law.number);
    
    [self.navigationController pushViewController:law animated:YES];
  

}


/*
#pragma mark - datasource
- (NSInteger)mTableView:(XDMultTableView *)mTableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}



- (XDMultTableViewCell *)mTableView:(XDMultTableView *)mTableView
              cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"cell";
    UITableViewCell *cell = [mTableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    UIView *view = [[UIView alloc] initWithFrame:cell.bounds] ;
    //    view.layer.backgroundColor  = [UIColor whiteColor].CGColor;
    
    
    view.layer.backgroundColor = [UIColor whiteColor].CGColor;
    view.layer.masksToBounds    = YES;
    view.layer.borderWidth      = 0.2;
    view.layer.borderColor      = [UIColor lightGrayColor].CGColor;
    
    cell.backgroundView = view;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (NSInteger)numberOfSectionsInTableView:(XDMultTableView *)mTableView{
    return 8;
}

-(NSString *)mTableView:(XDMultTableView *)mTableView titleForHeaderInSection:(NSInteger)section{
    //    return @"我是头部";
    if (section == 0) {
        return @"保险赔偿条例1";
    }
    else if (section == 1)
    {
        
        return @"保险赔偿条例2";
        
    }
    else if (section == 2)
    {
        
        return @"保险赔偿条例";
        
    }
    else if (section == 3)
    {
        
        return @"保险赔偿条例";
        
    }
    else
    {
        
        return @"么么哒";
        
        
    }
    
    
    
}

#pragma mark - delegate
- (CGFloat)mTableView:(XDMultTableView *)mTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 160;
}

- (CGFloat)mTableView:(XDMultTableView *)mTableView heightForHeaderInSection:(NSInteger)section{
    return 40;
}


- (void)mTableView:(XDMultTableView *)mTableView willOpenHeaderAtSection:(NSInteger)section{
    NSLog(@"即将展开");
}


- (void)mTableView:(XDMultTableView *)mTableView willCloseHeaderAtSection:(NSInteger)section{
    NSLog(@"即将关闭");
}

- (void)mTableView:(XDMultTableView *)mTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点击cell");
}
*/


@end
